package org.ling.xuan.entity;

import lombok.Data;
import org.ling.xuan.util.LxStrUtil;

import java.util.Map;

@Data
public class SvnInfo {
    /**
     * 本地路径 svn执行目录和当前文件的相对路径
     * 如：再 /d/svn-app/ifmonline/com.hundsun.lcpt.online.adapter/com/hundsun/lcpt/online/adapter/cancelerase 执行
     * 则是：  CancelBase.java
     */
    private String localRelativePath;
    /**
     * 本地根目录 D:\svn-app\ifmonline
     */
    private String localRoot;
    /**
     * 远程url  https://192.168.57.56/bank/depone/IFMS/%E7%BB%BC%E5%90%88%E7%90%86%E8%B4%A2%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9FV3.0/trunk/Sources/app/ifmonline/com.hundsun.lcpt.online.adapter/com/hundsun/lcpt/online/adapter/cancelerase/CancelBase.java
     */
    private String remoteUrl;
    /**
     * 远程后缀 ^/%E7%BB%BC%E5%90%88%E7%90%86%E8%B4%A2%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9FV3.0/trunk/Sources/app/ifmonline/com.hundsun.lcpt.online.adapter/com/hundsun/lcpt/online/adapter/cancelerase/CancelBase.java
     */
    private String remoteRelativePath;
    /**
     * 远程根目录  https://192.168.57.56/bank/depone/IFMS
     */
    private String remoteRoot;
    /**
     * 文件名称   CancelBase.java
     */
    private String name;
    /**
     * 文件uuId  31D9E168-BF60-1016-A248-9532DBE21C80
     */
    private String uuid;
    /**
     * 项目版本 902256
     */
    private String projectVersion;
    /**
     * 文件还是文件夹 file
     */
    private String type;
    /**
     * schedule normal
     */
    private String schedule;
    /**
     * 最后修改用户 mahui12039
     */
    private String lastChangeAuth;
    /**
     * 最后一次修改版本 900126
     */
    private String lastChangeVersion;
    /**
     * 最后一次修改时间 2023-07-28 09:20:04 +0800 (▒▒▒▒, 28 7▒▒ 2023)
     */
    private String lastChangeTime;
    /**
     * md5值 02cabb85b8e8054d698fdc3bef4a2225fc159255
     */
    private String checkSum;
    /**
     * 内容最后修改时间 2023-07-28 09:20:04 +0800 (▒▒▒▒, 28 7▒▒ 2023)
     */
    private String textLastUpdate;

    /**
     * 恒生版本，作者，修改信息
     */
    private HundSonInfo versionInfo;

    public SvnInfo(String cmdStr) {
        Map<String, String> map = LxStrUtil.convertMultiLineToMap(cmdStr,":");
        this.localRelativePath = map.getOrDefault("Path", "");
        this.localRoot = map.getOrDefault("Working Copy Root Path", "");
        this.remoteUrl = map.getOrDefault("URL", "");
        this.remoteRelativePath = map.getOrDefault("Relative URL", "");
        this.remoteRoot = map.getOrDefault("Repository Root", "");
        this.name = map.getOrDefault("Name", "");
        this.uuid = map.getOrDefault("Repository UUID", "");
        this.projectVersion = map.getOrDefault("Revision", "");
        this.type = map.getOrDefault("Node Kind", "");
        this.schedule = map.getOrDefault("Schedule", "");
        this.lastChangeAuth = map.getOrDefault("Last Changed Author", "");
        this.lastChangeVersion = map.getOrDefault("Last Changed Rev", "");
        this.lastChangeTime = map.getOrDefault("Last Changed Date", "");
        this.checkSum = map.getOrDefault("Text Last Updated", "");
        this.textLastUpdate = map.getOrDefault("Checksum", "");
    }
}
